package com.squirrel.michale;

import java.util.Arrays;

public class Day20250122_LeetCode001561 {


    public int maxCoins(int[] piles) {
        Arrays.sort(piles);
        int length = piles.length;
        int epoch = length / 3;
        int coins = 0;
        int index = length - 2;
        for (int i = 0; i < epoch; i++) {
            coins += piles[index];
            index -= 2;
        }
        return coins;
    }

    //        作者：力扣官方题解
//        链接：https://leetcode.cn/problems/maximum-number-of-coins-you-can-get/solutions/409109/ni-ke-yi-huo-de-de-zui-da-ying-bi-shu-mu-by-leetco/
//        来源：力扣（LeetCode）
//        著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。
}
